package com.example.admin.yuejian21.Adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.admin.yuejian21.Bean.Club;
import com.example.admin.yuejian21.Bean.train;
import com.example.admin.yuejian21.R;
import com.example.admin.yuejian21.ViewHolder.renqiViewHolder;

import com.example.admin.yuejian21.activity.ClubDetailActivity;

import java.util.ArrayList;
import java.util.List;

import it.sephiroth.android.library.picasso.Picasso;

/**
 * Created by Admin on 2017/10/15.
 */

public class RenqiAdapter extends RecyclerView.Adapter {
    private List<Club> ClubList =new ArrayList<>();

    private Context context;
    private LayoutInflater layoutInflater;
    public  static String id;
    public RenqiAdapter(Context context,List<Club> Clublist ) {
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        this.ClubList.addAll(Clublist);
    }
        @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View itemView =
                    layoutInflater.inflate(R.layout.renqi,parent,false);

            renqiViewHolder holder =
                    new renqiViewHolder(itemView);

            return holder;

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        renqiViewHolder renqiViewHolder =
                (renqiViewHolder) holder;
        final Club club = ClubList.get(position);

        String Clubname =club.getClub_name();





        renqiViewHolder.ClubnameView.setText(Clubname);





        Picasso
                .with(context)
                .load("http://172.24.10.175/workout/Uploads/"+ClubList.get(position).getThumb())


                .into(
                        renqiViewHolder .imageView);

        renqiViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, ClubDetailActivity.class);

                intent.putExtra("club",club);
                id = club.getId();

                context.startActivity(intent);

            }
        });
    }


    @Override
    public int getItemCount() {
        return ClubList.size();
    }
}
